package com.jimmy.dreamer;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class Dreamer extends Activity implements OnClickListener{
	
	public static boolean isLogin = false;
	public static Button btnLogin = null;
	private Button btnRecord = null;
	private Button btnView = null;
	private Button btnExit = null;
	
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        initView();
    }
    
    private void initView(){
    	if(isLogin){
    		btnLogin = (Button) findViewById(R.id.btn_login);
            btnLogin.setOnClickListener(this);
            btnLogin.setText("Logout");
    	}
    	else{
    		btnLogin = (Button) findViewById(R.id.btn_login);
            btnLogin.setOnClickListener(this);
            btnLogin.setText("Login");
    	}
        btnRecord = (Button) findViewById(R.id.btn_record);
        btnRecord.setOnClickListener(this);
        btnView = (Button) findViewById(R.id.btn_view);
        btnView.setOnClickListener(this);
        btnExit = (Button) findViewById(R.id.btn_exit);
        btnExit.setOnClickListener(this);
        
       
    }
    
    public void onClick(View v){
    	switch(v.getId()){
    	case R.id.btn_login:
    		if(isLogin){
    			isLogin = false;
    			btnLogin.setText("Login");
    		}
    		else{
        		Intent l = new Intent(this, Login.class);
        		startActivity(l);
    		}
    		break;
    		
    	case R.id.btn_record:
    		Intent r = new Intent(this, Record.class);
    		startActivity(r);
    		break;
    		
    	case R.id.btn_exit:
    		Intent intent = new Intent(Intent.ACTION_MAIN);
    		intent.addCategory(Intent.CATEGORY_HOME);
    		intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    		startActivity(intent);
    		break;	
    		
    	case R.id.btn_view:
    		Intent r1 = new Intent(this, ViewDream.class);
    		startActivity(r1);
    		break;
    	}
    }
}